(function () {
    window.Map = function () {
            this.codeMap = [
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],
            ]
        },
        Map.prototype.render = function (mapGame) {
            for (let i = 0; i < mapGame.row; i++) {
                for (let j = 0; j < mapGame.col; j++) {
                    if (this.codeMap[i][j] != 0) {
                        game.setColor(i, j, this.codeMap[i][j])
                    }
                }
            }
        }
    //判断是否可以消行
    Map.prototype.checkRemove = function () {
        for (let i = 0; i < 20; i++) {
            if (this.codeMap[i].indexOf(0) == -1) {
                this.codeMap.splice(i, 1);
                this.codeMap.unshift([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
                if (game.during <= 30 && game.during >= 20) {
                    game.score += 10;
                } else if (game.during < 20 && game.during >= 10) {
                    game.score += 20;
                } else {
                    game.score += 30;
                }

                document.getElementById("score").innerHTML = "分数：" + game.score;
                if (game.score % 100 == 0) {
                    game.during -= 5;
                    if (game.during < 0) {
                        game.during = 1;
                    }
                }
            }
        }
    }
})()